const http = require('http')

// get
// http.get({host:'localhost',port:3000,path:'/user?a=1'},res=>{
//     console.log(res.headers)
// })

// post
const options = {
    host: 'localhost',
    port: 3000,
    path: '/user?a=1',
    method: 'POST',
    headers:{
        'content-type':'application/json'
    }
}
const req = http.request(options, (res) => {
    const buffer = []
    res.on('data',(chunk)=>{
        buffer.push(chunk)
    })
    res.on('end',()=>{
        let obj = Buffer.concat(buffer).toString()
        console.log(obj)
    })
   
})
req.end('{"age":123}')

